package com.woniuxy.boot.common.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Document(indexName = "espolicy")
@Data
public class EsPolicy implements Serializable {

    /**
     *
     */
    @Id
    private Long id;

    @Field(type = FieldType.Text , value = "name")
    private String name;

    @Field(type = FieldType.Text , value = "phone")
    private String phone;

    @Field(type = FieldType.Text , value = "no")
    private String no;

    @Field(type = FieldType.Text , value = "carNumber")
    private String carNumber;

    @Field(type = FieldType.Text , value = "frameNumber")
    private String frameNumber;

    @Field(type = FieldType.Nested , value = "insurances")
    private List<Insurance> insurances;

    @Field(type = FieldType.Text , value = "brand")
    private String brand;

    @Field(type = FieldType.Text , value = "startTime")
    private LocalDateTime startTime;

    @Field(type = FieldType.Date , value = "endTime",format = {},pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd'T'HH:mm:ss'+08:00' || strict_date_optional_time || epoch_millis")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime endTime;

    @Field(type = FieldType.Text , value = "status")
    private  String status;
}
